/*
 * @Author: liuzelin
 * @Date: 2024-04-20 11:07:16
 * @LastEditors: liuzelin
 * @LastEditTime: 2024-04-21 20:50:43
 * @Description: file content
 */
#include "panda_event_impl.hpp"
#include "panda_log.hpp"
#include "panda_thread_impl.hpp"
#include "panda_uv_helper.hpp"

using namespace PandaImpl;

UVAsync::UVAsync(ThreadImpl *thread) {
  this->thread_ = thread;
  this->isClosed = false;
  this->handler = &async_;
  int ret = uv_async_init(thread->GetLoop(), &async_, &UVHelper::UVAsyncCb);
  PandaCheck(ret == 0) << " Ret:" << ret << " Error:" << uv_err_name(ret);
  uv_handle_set_data((uv_handle_t *)&this->async_, this);
}
void UVAsync::Wait(int64_t ms) {}

void UVAsync::Set() { uv_async_send(&async_); }